# 新增数据
# heros = {'及时雨':'宋江','玉麒麟':'卢俊义','花和尚':'鲁智深','小李广':'花荣'}
# heros['豹子头'] = '林冲'
# print(heros)

# 修改数据
# heros['及时雨'] = '宋公明'
# print(heros)
# dict_val = {'黑旋风':'李逵','入云龙':'公孙胜','花和尚':'鲁达'}
# heros.update(dict_val)
# print(heros)

# 删除 del pop popitem clear
heros1 = {'及时雨':'宋江','玉麒麟':'卢俊义','花和尚':'鲁智深','小李广':'花荣'}
# del(heros1['及时雨'])
# print(heros1)
# del(heros1)
# print(heros1)

# 使用pop
# heros1.pop('及时雨')
# print(heros1)
# heros1.pop('aaa') # KeyError: 'aaa'

# 使用popitem 删除最后一个元素
# heros1.popitem()
# print(heros1)

# clear 清空字典
# heros1.clear()
# print(heros1)

# 查询 in
# if '及时雨' in heros1:
#     print('该元素存在')
# else:
#     print('该元素不存在')

# 取值
# keys = heros1.keys()
# print(keys)
# 将keys转换成列表
# print(list(keys))
# for item in list(keys):
#     print(item)

# values = heros1.values()
# print(values)
# print(list(values))
# for item in list(values):
#     print(item)

# items = heros1.items()
# print(items)
# print(list(items))
# k,v = list(items)[0]
# print(k,v)
# for item in list(items):
#     print(item)


# 复制
heros2 = heros1.copy()
print(id(heros1),id(heros2))